GAE Python Practice

cache 機制(2種)

cache
1
2
3
4
5
class Test2(webapp2.RequestHandler):

def get(self):
self.response.headers.add_header('cache-control','public, max-age=7200') # 2hr cache

cache
1
2
3
- url: /images
static_dir: static/images

Read More

IOS Delegate

宣告

宣告protocol

@required是指採用這個protocol的類別一定要實現這個方法
且預設是指@required

@optional是指採用這個protocol的類別可以選擇性實現這個方法

英文字屬於哪個修飾子

  • @required: a b c d g h
  • @optional: e f
Template.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
@class Template;
@protocol TemplateDelegate<NSObject>
//a
//b
@required
-(void)TemplateView:(Template*)templateView WithValueChangeRequired:(float)value;
//c
//d
@optional
-(void)TemplateView:(Template*)templateView WithValueChangeOptional:(float)value;
//e
//f
@required
//g
//h
@end
Read More

python GAE django

這邊先跳過了去developers console 申請專案的步驟!!!

一開始先提供兩個連結,感覺蠻重要的:

  1. Documetation
  2. App Engine “Hello World” Starter

因為還是不曉得如何配置django到GAE上,剛好上面連結2有現成的配置(Yay!)

Read More

Github Public Key

最近狀況還挺多的

沒想到連Blog上傳都有問題XD

因為Blog放在Github,又懶得去搞SSH

所以只好把Github.app開著,一邊上傳Blog(很懶的做法,但是很有效)

但是經過昨天起肖,把keychain內的東西全部砍了

結論最後Github.app就一整個死給我看(怒

Github Help的這篇Generating SSH Keys是相當完整的解決方案

Step 2: Generate a new SSH key

ssh-keygen -t rsa -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
# Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

Enter passphrase (empty for no passphrase): [Type a passphrase]
Enter same passphrase again: [Type passphrase again]

# start the ssh-agent in the background
eval "$(ssh-agent -s)"
# Agent pid 59566
ssh-add ~/.ssh/id_rsa

Step 3: Add your SSH key to GitHub

$ pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard

做到這個步驟會把rsa複製到剪貼簿

接著再去Github -> Settings -> SSH Keys -> Add SSH Key

Step 4: Test everything out

ssh -T git@github.com
# Attempts to ssh to github

Library not loaded: @rpath/libswiftCore.dylib

最近聽到有人說他的Swift不能夠使用,沒想到這次我也遇到了

症狀是Swift照常正常運作(語法高亮,自動完成,Build等等)

唯獨就只有runtime的時候不能夠執行,且顯示一些莫名其妙的話

Library not loaded: @rpath/libswiftCore.dylib

解答其實就在這篇xcode gm ios 8 gm swift today extension crash in simulator and device: Library not loaded: @rpath/libswiftCore.dylib

我的解藥是下面這條

Build settings -> "Embeded content contains Swift Code" -> YES

Android apk sign

這次事件的原因源於想要雙人去Build同一份Android專案,然後把Apk發佈出去安裝。

但是這樣會發生衝突

即便是使用adb install,還是會發生

Failure [INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES]

從這一篇How to fix “Install Parse Failed - Inconsistent Certificates” when installing .APK file有提到說:

  1. Copy the first machine’s debug.keystore file to the second machine. See: How to deal with INSTALL_PARSE_FAILED_INCONSISTENT_CERTIFICATES without uninstallation on StackOverflow.
  2. Completely uninstall the application first and then install again. You may have to do this if you don’t have the debug.keystore file for some reason. Perhaps your Jenkins CI build has a different release keystore.

跟網路上的講法幾乎都是一樣,不外乎就是uninstall,但是發佈出去的版本是從bin拿出來用的

也就是說是經由debug.keystore所產生的。

Read More

IOS Custom View 三部曲 Part 2 (Live Render)

Repo來源:CustomView

Live Render是IOS8之後才特有的功能,它提供了將你的Code可以在Storyboard上面即時的顯示,而不用再runtime的時候才能看見

  • Creating a Custom View that Renders in Interface Builder
    • By using the IBInspectable attribute to declare variables as inspectable properties, you allow Interface Builder to quickly rerender your custom view as you change the values of these properties in the Attributes inspector. You can attach the IBInspectable attribute to any property in a class declaration, class extension, or category for any type that’s supported by Interface Builder’s defined runtime attributes: boolean, integer or floating point number, string, localized string, rectangle, point, size, color, range, and nil.
    • If you need to create code for a custom view that runs only in Interface Builder, call that code from the method prepareForInterfaceBuilder. For example, while designing an app that uses the iPhone camera, you might want to draw an image that represents what the camera might capture. Although its compiled for runtime, code called from prepareForInterfaceBuilder never gets called except by Interface Builder at design time.
    • You can use the preprocessor macro TARGET_INTERFACE_BUILDER to specify code for inclusion with or exclusion from your custom view class.

簡而言之,Live Render能使用的資料型態就是User Defined Runtime Attributes所能提供的資料型態。

User Defined Runtime Attributes

Read More

IOS Custom View 三部曲 Part 1 (Custom View With xib)

Repo來源:CustomView
相關檔案:

Step 1

  • 建立一個CustomView類別,並且繼承自UIView
    ex: CustomView.h & CustomView.m

  • 然後,接著建立同名的xib檔案
    ex: CustomView.xib

Read More

Package Managment

Homebrew

Python

pip

http://pip.readthedocs.org/en/latest/installing.html

Update Package
pip install Django --upgrade

pip install Django -U

Android Silent Install Apk

這次要完成一個能夠自動更新的APP

但是又必須符合以下條件:

  • 不打算放在Google Store
  • 不需要手動認證安裝(避開Installer,你真的要安裝嗎?->確定。這件事)
Read More